USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Importance-Insert]    Script Date: [[20120914064956]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064956]]
-- Description:	Insert record into table [dbo].[Importance]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Importance-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Importance-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Importance-Insert]
	/*@Importance_RowNumber int =Null OUTPUT , 
	@Importance_ID uniqueidentifier =Null  , 
	@Importance_Code varchar(50) =Null  , 
	@Importance_NameAr varchar(300) =Null  , 
	@Importance_NameEn varchar(300) =Null  , 
	@Importance_Notes varchar(max) =Null  , 
	@Importance_Search varchar(max) =Null  , 
	@Importance_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[Importance](/*[Importance_ID], [Importance_Code], [Importance_NameAr], [Importance_NameEn], [Importance_Notes], [Importance_Search]*/)
	VALUES     (/*@Importance_ID, @Importance_Code, @Importance_NameAr, @Importance_NameEn, @Importance_Notes, @Importance_Search*/)

	/*SELECT @Importance_RowNumber = [Importance_RowNumber], @Importance_TimeStamp = [Importance_TimeStamp]
    FROM [dbo].[Importance]
    WHERE  ( [Importance_ID] =@Importance_ID )
	AND  ( [Importance_Code] =@Importance_Code )
	AND  ( [Importance_NameAr] =@Importance_NameAr )
	AND  ( [Importance_NameEn] =@Importance_NameEn )
	AND  ( [Importance_Notes] =@Importance_Notes )
	AND  ( [Importance_Search] =@Importance_Search )*/
END
GO
-- =============================================
USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Importance-update]    Script Date: [[20120914064956]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064956]]
-- Description:	Update record in table [dbo].[Importance]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Importance-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Importance-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Importance-update]
	/*@Importance_RowNumber int =Null OUTPUT , 
	@Importance_ID uniqueidentifier =Null  , 
	@Importance_Code varchar(50) =Null  , 
	@Importance_NameAr varchar(300) =Null  , 
	@Importance_NameEn varchar(300) =Null  , 
	@Importance_Notes varchar(max) =Null  , 
	@Importance_Search varchar(max) =Null  , 
	@Importance_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [Importance_TimeStamp]
    FROM [dbo].[Importance]
    	WHERE ([Importance_ID] = @Importance_ID)

    IF  @OldTimeStamp = @Importance_TimeStamp
    BEGIN*/
		Update [dbo].[Importance] SET 
		/*[Importance_ID] =@Importance_ID, 
		[Importance_Code] =@Importance_Code, 
		[Importance_NameAr] =@Importance_NameAr, 
		[Importance_NameEn] =@Importance_NameEn, 
		[Importance_Notes] =@Importance_Notes, 
		[Importance_Search] =@Importance_Search*/
		/*WHERE ([Importance_ID] = @Importance_ID)*/
	/*END*/

	/*SELECT @Importance_RowNumber = [Importance_RowNumber], @Importance_TimeStamp = [Importance_TimeStamp]
    FROM [dbo].[Importance]
	WHERE ([Importance_ID] = @Importance_ID)*/
END
GO
-- =============================================
USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Importance-Insert-Update]    Script Date: [[20120914064956]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064956]]
-- Description:	Insert OR Update record into table [dbo].[Importance]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Importance-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Importance-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Importance-Insert-Update]
	/*@Importance_RowNumber int =Null OUTPUT , 
	@Importance_ID uniqueidentifier =Null  , 
	@Importance_Code varchar(50) =Null  , 
	@Importance_NameAr varchar(300) =Null  , 
	@Importance_NameEn varchar(300) =Null  , 
	@Importance_Notes varchar(max) =Null  , 
	@Importance_Search varchar(max) =Null  , 
	@Importance_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[Importance] 
					/*WHERE ([Importance_ID] = @Importance_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[Importance](/*[Importance_ID], [Importance_Code], [Importance_NameAr], [Importance_NameEn], [Importance_Notes], [Importance_Search]*/)
		VALUES     (/*@Importance_ID, @Importance_Code, @Importance_NameAr, @Importance_NameEn, @Importance_Notes, @Importance_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [Importance_TimeStamp]
		FROM [dbo].[Importance]
    	WHERE ([Importance_ID] = @Importance_ID)

		IF  @OldTimeStamp = @Importance_TimeStamp
		BEGIN*/
			Update [dbo].[Importance] SET 
			/*[Importance_ID] =@Importance_ID, 
			[Importance_Code] =@Importance_Code, 
			[Importance_NameAr] =@Importance_NameAr, 
			[Importance_NameEn] =@Importance_NameEn, 
			[Importance_Notes] =@Importance_Notes, 
			[Importance_Search] =@Importance_Search*/
			/*WHERE ([Importance_ID] = @Importance_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @Importance_RowNumber = [Importance_RowNumber], @Importance_TimeStamp = [Importance_TimeStamp]
    FROM [dbo].[Importance]
	WHERE ([Importance_ID] = @Importance_ID)*/
END
GO
-- =============================================
USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Importance-Delete]    Script Date: [[20120914064956]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064956]]
-- Description:	delete records from table [dbo].[Importance] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Importance-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Importance-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Importance-Delete]
	/*@Importance_RowNumber int =null  , 
	@Importance_ID uniqueidentifier =null  , 
	@Importance_Code varchar(50) =null  , 
	@Importance_NameAr varchar(300) =null  , 
	@Importance_NameEn varchar(300) =null  , 
	@Importance_Notes varchar(max) =null  , 
	@Importance_Search varchar(max) =null  , 
	@Importance_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[Importance]
	WHERE /*( [Importance_RowNumber] = ISNULL(@Importance_RowNumber, [Importance_RowNumber]) )
	AND ( [Importance_ID] = ISNULL(@Importance_ID, [Importance_ID]) )
	AND ( [Importance_Code] like ISNULL(@Importance_Code, [Importance_Code]) )
	AND ( [Importance_NameAr] like ISNULL(@Importance_NameAr, [Importance_NameAr]) )
	AND ( [Importance_NameEn] like ISNULL(@Importance_NameEn, [Importance_NameEn]) )
	AND ( [Importance_Notes] like ISNULL(@Importance_Notes, [Importance_Notes]) )
	AND ( [Importance_Search] like ISNULL(@Importance_Search, [Importance_Search]) )
	AND ( [Importance_TimeStamp] = ISNULL(@Importance_TimeStamp, [Importance_TimeStamp]) )*/
END
GO
-- =============================================
USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Importance-Select]    Script Date: [[20120914064956]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064956]]
-- Description:	select records from table [dbo].[Importance] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Importance-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Importance-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Importance-Select]
	/*@Importance_RowNumber int =null  , 
	@Importance_ID uniqueidentifier =null  , 
	@Importance_Code varchar(50) =null  , 
	@Importance_NameAr varchar(300) =null  , 
	@Importance_NameEn varchar(300) =null  , 
	@Importance_Notes varchar(max) =null  , 
	@Importance_Search varchar(max) =null  , 
	@Importance_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[Importance]
	WHERE /*( [Importance_RowNumber] = ISNULL(@Importance_RowNumber, [Importance_RowNumber]) )
	AND ( [Importance_ID] = ISNULL(@Importance_ID, [Importance_ID]) )
	AND ( [Importance_Code] like ISNULL(@Importance_Code, [Importance_Code]) )
	AND ( [Importance_NameAr] like ISNULL(@Importance_NameAr, [Importance_NameAr]) )
	AND ( [Importance_NameEn] like ISNULL(@Importance_NameEn, [Importance_NameEn]) )
	AND ( [Importance_Notes] like ISNULL(@Importance_Notes, [Importance_Notes]) )
	AND ( [Importance_Search] like ISNULL(@Importance_Search, [Importance_Search]) )
	AND ( [Importance_TimeStamp] = ISNULL(@Importance_TimeStamp, [Importance_TimeStamp]) )*/
END
GO
-- =============================================
